package com.zzdz.system.service.impl;

import com.zzdz.system.entity.Dict;
import com.zzdz.system.service.IDictService;
import com.zzdz.system.service.ISelectCommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SelectCommonServiceImpl implements ISelectCommonService {

    @Autowired
    private IDictService dictService;

    @Override
    public List<Map<String, Object>> getDictList() {
        List<Dict> dictList = dictService.findDicts(new Dict());
        if (dictList != null && dictList.size() > 0){
            List<Map<String, Object>> result = new ArrayList<>();
            dictList.forEach(item->{
                Map<String, Object> map = new HashMap<>();
                map.put("id", item.getId());
                map.put("name", item.getType());
                result.add(map);
            });
            return result;
        }
        return null;
    }
}
